Post not yet marked as solved
Click to stop watching this thread.
You have stopped watching this post. Click to start watching again.
contentPostList.repliesup-voted.tooltip
UIViewControllerRepresentable
SwiftUI MIDI Bluetooth example
Content View:
@State private var btScan = false
@State private var btAdvertise = false
var body: some View {
VStack {
Button("Bluetooth MIDI Scan") { self.btScan = true }
.sheet(isPresented: $btScan) { BTConnectController(btScan: self.$btScan) }
Button("Bluetooth Advertise") { self.btAdvertise = true }
.sheet(isPresented: $btAdvertise) { BTPeripheralController(btAdvertise: self.$btAdvertise) }
}
.padding()
}
struct BTConnectController : UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> CABTMIDICentralViewController {
CABTMIDICentralViewController()
}
func updateUIViewController(_ uiViewController: CABTMIDICentralViewController, context: Context) {
}
typealias UIViewControllerType = CABTMIDICentralViewController
@Binding var btScan: Bool
}
struct BTPeripheralController : UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> CABTMIDILocalPeripheralViewController {
CABTMIDILocalPeripheralViewController()
}
func updateUIViewController(_ uiViewController: CABTMIDILocalPeripheralViewController, context: Context) {
}
typealias UIViewControllerType = CABTMIDILocalPeripheralViewController
@Binding var btAdvertise: Bool
}
Hope it helps, @JSE98
Best regards
Andreas